{% include "../../header.html" %}
{% include "../../navigation.html" %}

<div class="wrapper">
    <div class="container-fluid">

        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="page-title-box">
                    <div class="btn-group pull-right">
                        <h4 class="page-title">Edit User</h4>
                    </div>
                    <ol class="breadcrumb hide-phone p-0 m-0">
                        <li class="breadcrumb-item"><a href="#">HuntCMS</a></li>
                        <li class="breadcrumb-item"><a href="#">Role</a></li>
                        <li class="breadcrumb-item active">Edit Role</li>
                    </ol>
                </div>
            </div>
        </div>
        <!-- end page title end breadcrumb -->

        <div class="row">
            <div class="col-12">
                <div class="card-box">
                    <h4 class="m-t-0 header-title">Edit Role</h4>
                    <p class="text-muted m-b-30 font-14">
                        Edit admin role.
                    </p>


                    <div class="row">
                        <div class="col-12">
                            <div class="p-20">
                                <form class="form-horizontal" role="form" action="{{ url('system.role.edit' , '')}}?id={{role.id}}" method="post">
                                    <div class="form-group row">
                                        <label class="col-2 col-form-label">Name</label>
                                        <div class="col-10">
                                            <input type="text" name="name" value="{{role.name}}" class="form-control" required data-parsley-maxlength="12" placeholder="Please enter your nickname...">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-2 col-form-label">Role</label>
                                        <div class="col-10">
                                            <div class="mt-3">

                                                {% for group in groups %}
                                                <div class="group-div" style="font-weight: 500; color: #4c5667; margin-top: {% if loop.index == 1 %}-1rem;{% else %}0.5rem;{% endif %}">{{ loop.index }} - {{ group.title }}</div>
                                                <div>
                                                    {% for rolePermission in rolePermissions %}
                                                        {% if rolePermission.permission.group_id == group.id %}
                                                        <div class="custom-control custom-checkbox" style="display: inline-block;">
                                                            <input type="checkbox" {{ rolePermission.checked }} name="permissionid_{{rolePermission.permission.id}}" class="custom-control-input" value="{{rolePermission.permission.id}}" id="customCheck{{rolePermission.permission.id}}">
                                                            <label onselectstart="return false" class="custom-control-label" for="customCheck{{rolePermission.permission.id}}">{{rolePermission.permission.title}}</label>
                                                        </div>
                                                        {% endif %}
                                                    {% endfor %}
                                                </div>
                                                {% endfor %}

                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-2 col-form-label">Status</label>
                                        <div class="col-10">
                                            <div class="custom-control custom-radio">
                                                <input type="radio" {% if role.status == 1 %}checked{% endif %} id="customRadio1" value="1" name="status" class="custom-control-input">
                                                <label onselectstart="return false" class="custom-control-label" for="customRadio1">{{ trans("COMMON_SYSTEM_ENABLED") }}</label>
                                            </div>
                                            <div class="custom-control custom-radio">
                                                <input type="radio" {% if role.status == 0 %}checked{% endif %} id="customRadio2" value="0" name="status" class="custom-control-input">
                                                <label onselectstart="return false" class="custom-control-label" for="customRadio2">{{ trans("COMMON_SYSTEM_DISABLED") }}</label>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group mb-0 justify-content-end row">
                                        <div class="col-md-10">
                                            <button type="submit" class="btn btn-info waves-effect waves-light">Create</button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>

                    </div>
                    <!-- end row -->

                </div> <!-- end card-box -->
            </div><!-- end col -->
        </div>
        <!-- end row -->

    </div> <!-- end container -->
</div>
<!-- end wrapper -->

{% include "../../footer.html" %}
<!-- Parsleyjs -->
<script type="text/javascript" src="/assets/vendor/parsleyjs/dist/parsley.min.js"></script>
<script>
    $(document).ready(function() {
        $('form').parsley();
    });
</script>